<!--计费设置-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>计费设置</title>
    <link rel="stylesheet" href="../css/layui.css">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <style type="text/css">
  		 a:link{
            text-decoration:none;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">MISS后台管理系统</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    username
                </a>
            </li>
            <li class="layui-nav-item"><a href="">注销</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <!-- 侧边导航: <ul class="layui-nav layui-nav-tree layui-nav-side"> -->
                <li class="layui-nav-item">
                    <a href="index.html">首页</a>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">散客开单</a>
                    <dl class="layui-nav-child">
                        <dd><a href="Guests_check_in.html">宾客入住</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">订单</a>
                    <dl class="layui-nav-child">
                        <dd><a href="Order.html">所有订单</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">宾客结账</a>
                    <dl class="layui-nav-child">
                         <dd><a href="Ordinary_invoicing.html" >结账</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">预定管理</a>
                    <dl class="layui-nav-child">
                    <dd><a href="Query_book.html">查询预定</a></dd>
                        <dd><a href="Add_a_reservation.html">添加预定</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">营业查询</a>
                    <dl class="layui-nav-child">
                        <dd><a href="Check-in_guest_enquiry.html">入住宾客查询</a></dd>
                        <dd><a href="Member_of_the_query.html">会员查询</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">系统设置</a>
                    <dl class="layui-nav-child">
                        <dd><a href="Data_management.html">数据管理</a></dd>
                        <dd><a href="VIP_set_up.html">VIP设置</a></dd>
                        <dd><a href="Billing_Settings.html" style="background-color: #1E90FF">计费设置</a></dd>
                        <dd><a href="Set_up_the_room.html">房间设置</a></dd>
                        <dd><a href="Operator_setup.html">操作员设置</a></dd>
                    </dl>
                </li>
                 <li class="layui-nav-item">
                    <a href="javascript:;">订单信息</a>
                    <dl class="layui-nav-child">
                    <dd><a href="javascript:void(0);" onclick="tan()">查看订单信息</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <div style="padding: 15px;">
        	<div class="layui-tab layui-tab-card" >
			  <ul class="layui-tab-title">
			    <li class="layui-this">房间打折</li>
			    <li>会员打折</li>
			  </ul>
        	<div id="ltc" class="layui-tab-content" style="height: 680px;">
			    <div class="layui-tab-item layui-show">
				    <div class="t_content" style="height: 550px;">
				    	<table class="layui-table"  lay-even lay-skin="row" lay-size="lg">
					    	<thead>
					    		<tr>
					    			<th>房间类型</th>
					    			<th>房间优惠</th>
					    			<th>操作</th>
					    		</tr>
					    	</thead>
					    	<tbody id="typetbody">
					    		<tr>
					    			<td>豪华房</td>
					    			<td>9.5折</td>
					    			<td><input class="layui-btn" type="button" value="修改优惠" data-toggle="modal" data-target="#myModal"></input></td>
					    		</tr>
					    	</tbody>
				    	</table>
				    </div>
			 	</div>
			    <div class="layui-tab-item">
			    	<div class="t_content" style="height: 550px;">
				    	<table class="layui-table"  lay-even lay-skin="row" lay-size="lg">
					    	<thead>
					    		<tr>
					    			<th>会员等级</th>
					    			<th>会员优惠</th>
					    			<th>升级条件</th>
					    			<th>操作</th>
					    		</tr>
					    	</thead>
					    	<tbody id="viptbody">
					    		<tr>
					    			<td>大众会员</td>
					    			<td>9.5折</td>
					    			<td><input class="layui-btn" type="button" value="修改优惠" data-toggle="modal" data-target="#myModal1"></input></td>
					    		</tr>
					    		<tr>
					    			<td>白金会员会员</td>
					    			<td>8折</td>
					    			<td><input class="layui-btn" type="button" value="修改优惠" data-toggle="modal" data-target="#myModal1"></input></td>
					    		</tr>
					    		<tr>
					    			<td>黑卡会员</td>
					    			<td>7折</td>
					    			<td><input class="layui-btn" type="button" value="修改优惠" data-toggle="modal" data-target="#myModal1"></input></td>
					    		</tr>
					    	</tbody>
				    	</table>
				    </div>
			    </div>
			</div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © MISS酒店
    </div>
    

    
    
</div>
 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
  <div class="modal-dialog" style="z-index: 1041;">
    <div class="modal-content" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">修改房间优惠</h4>
      </div>
      <div class="modal-body">
        <form action="" enctype="multipart/form-data" method="post" role="form"  id="addvip">
        	<div style="display: inline-block;width: 400px;" class="form-group">
	           		<div class="form-group" style="margin-top: 20px;">
	           			<label for="cla.name">房间类型：</label>
	           			<span id="show_typename"></span>
	           		</div>
	           		<div class="form-group" style="margin-top: 20px;">
	           			<label for="cla.name">房间价格：</label>
	           			<span id="show_typeprice"></span>
	           		</div>
	           		<div class="form-group">
		    			<label style="margin-bottom: 10px;float: left;margin-top: 10px;">设置优惠：</label>
		    			<div class="row" style="display: inline-block;">
		    				<div class="col-md-5" >
		    					<input style="display: inline-block;width: 140px;" type="text" class="form-control" id="dis"  placeholder="请输入0到1之间">
		    				</div>
		    			</div>
		           	</div>
	           </div>
    		<div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		        <button type="button" class="btn btn-primary" onclick="changedis()">提交</button>
	     	</div>
        </form>
       </div>
    </div>
  </div>
</div><!-- /.modal -->
 <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
  <div class="modal-dialog" >
    <div class="modal-content" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">修改vip</h4>
      </div>
      <div class="modal-body">
        <form action="" enctype="multipart/form-data" method="post" role="form"  id="changevip">
        	<div style="display: inline-block;width: 400px;" class="form-group">
	           		<div style="margin-top: 20px;">
	           			<label for="cla.name">会员等级：</label>
	           			<span id="show_vipname"></span>
	           		</div>
	           		<div style="margin-top: 20px;">
	           			<label for="cla.name">会员优惠：</label>
	           			<span id="show_vipprice"></span>
	           		</div>
	           		<div style="margin-top: 20px;">
	           			<label for="cla.vipstock">升级金额：</label>
	           			<span id="show_vipcard"></span>
	           		</div>
	           		<div class="form-group">
		    			<label style="margin-bottom: 10px;float: left;margin-top: 10px;">设置优惠：</label>
		    			<div class="row" style="display: inline-block;">
		    				<div class="col-md-5" >
		    					<input style="display: inline-block;width: 240px;" type="text" class="form-control" id="vipdiscounts" name="discounts" placeholder="请输入0到1之间">
		    				</div>
		    			</div>
		           	</div>
		           	<div class="form-group">
		    			<label style="margin-bottom: 10px;float: left;margin-top: 10px;">升级条件：</label>
		    			<div class="row" style="display: inline-block;">
		    				<div class="col-md-5" >
		    					<input style="display: inline-block;width: 240px;" type="text" class="form-control" id="quota" name="quota" placeholder="请输入升级所需金额">
		    				</div>
		    			</div>
		           	</div>
	           </div>
    		<div class="modal-footer">
		        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		        <button type="button" class="btn btn-primary" onclick="change()">提交</button>
	     	</div>
        </form>
       </div>
    </div>
  </div>
</div><!-- /.modal -->
 <div class="modal fade" id="webSocketModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
  <div class="modal-dialog" style="height: 300px">
    <div class="modal-content" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">订单信息</h4>
      </div>
      <div class="modal-body" style="height: 300px">
        <div class="form-group" style="float: left;"></br>
			 <textarea id="message_content" class="form-control" readonly="readonly" cols="80" rows="10"></textarea>
		</div>
       </div>
    </div>
  </div>
</div><!-- /.modal -->
<script src="../js/layui.all.js"></script>
<script src="../js/jquery.min.js"></script>
<script src="../bt/modal.js"></script>
<script src="https://cdn.bootcss.com/jquery.serializeJSON/2.9.0/jquery.serializejson.min.js"></script>
<script>
var rtid ;
var uid;
layui.use(['element', 'layer'], function(){
  var element = layui.element
  ,layer = layui.layer;
  
  element.on('tab(docDemoTabBrief)', function(data){
    layer.msg('切到到了'+ data.index + '：' + this.innerHTML);
  });
});
$(function(){
	$.ajax({
		url:"/roomtype",
		type:"get",
		async:true,
		dataType:"json",
		success:function(mes){
			console.info(mes)
			var str = "";
			for (var i = 0; i < mes.length; i++) {
				var dis = mes[i].discounts*10;
				if(dis==10){
					dis="不打折";
				}else{
					dis = dis +"折";
				}
				str+="<tr><td>"+mes[i].name+"</td><td>"+dis+"</td><td>"+
				"<button class='layui-btn' type='button'  data-toggle='modal' data-target='#myModal'>修改优惠<input type='hidden' value='"+mes[i].id+"'/> </button></td></tr>";
			}
			$("#typetbody").html(str);
		}
	})
	
	$.ajax({
		url:"/vip",
		type:"get",
		async:true,
		dataType:"json",
		success:function(mes){
			console.info(mes)
			var list = mes.map.list
			var str = "";
			for (var i = 0; i < list.length; i++) {
				var dis = list[i].discounts*10;
				if(dis==10){
					dis="不打折";
				}else{
					dis+="折";
				}
				str+="<tr><td>"+list[i].message+"会员"+"</td><td>"+dis+"</td><td>"+list[i].quota+"</td><td><button class='layui-btn' type='button' data-toggle='modal' data-target='#myModal1'>修改优惠<input type='hidden' value='"+list[i].id+"'/></button></td></tr>"
			}
			$("#viptbody").html(str)
		}
	}) 
})
function show(){
	$.ajax({
		url:"/roomtype",
		type:"get",
		async:true,
		dataType:"json",
		success:function(mes){
			console.info(mes)
			var str = "";
			for (var i = 0; i < mes.length; i++) {
				var dis = mes[i].discounts*10;
				if(dis==10){
					dis="不打折";
				}else{
					dis = dis +"折";
				}
				str+="<tr><td>"+mes[i].name+"</td><td>"+dis+"</td><td>"+
				"<button class='layui-btn' type='button'  data-toggle='modal' data-target='#myModal'>修改优惠<input type='hidden' value='"+mes[i].id+"'/> </button></td></tr>";
			}
			$("#typetbody").html(str);
		}
	})
	
	
}
$('#myModal').on('show.bs.modal', function (e){
   rtid = $(e.relatedTarget).children("input").val();
	var pri ;
	 $.ajax({
		url:"/roomtype/"+rtid,
	 	type:"get",
	 	async:true,
		dataType:"json",
		success:function(mes){
		pri = mes.price+"  人民币/天"
			$("#show_typename").html(mes.name);
			$("#show_typeprice").html(pri)
		}
	}) 
})
function changedis(){
	var price = $("#dis").val();
	var res = {"id":rtid,"discounts":price}
	console.info(res)
	$.ajax({
		url:"/roomtype",
		type:"put",
		async:true,
		data:JSON.stringify(res),
		contentType:"application/json;charset=utf-8",
		success:function(mes){
			alert(mes)
			$('#myModal').modal('hide');
			show()
		}
	})
}
$('#myModal').on('hidden.bs.modal', function (){
	$("#dis").val("");
})
$('#myModal1').on('show.bs.modal', function (e){
	uid=$(e.relatedTarget).children("input").val();
	$.ajax({
		url:"/vip/"+uid,
		type:"get",
		async:true,
		dataType:"json",
		success:function(mes){
			console.info(mes)
			var vip = mes.message+"会员"
			var dis = mes.discounts*10;
			if(dis==10){
				dis="不打折";
			}else{
				dis+="折";
			}
			var quota ="￥"+ mes.quota
			$("#show_vipname").html(vip)
			$("#show_vipprice").html(dis)
			$("#show_vipcard").html(quota)
		}
	})
})
function change(){
	var vip = $('#changevip').serializeJSON();
	vip.id=uid;
	$.ajax({
		url:"/vip",
		type:"put",
		dataType:"json",
		data:JSON.stringify(vip),
		contentType:"application/json;charset=utf-8",
		success:function(mes){
			alert(mes.message)
			$("#myModal1").modal('hide')
			
			$.ajax({
				url:"/vip",
				type:"get",
				async:true,
				dataType:"json",
				success:function(mes){
					console.info(mes)
					var list = mes.map.list
					var str = "";
					for (var i = 0; i < list.length; i++) {
						var dis = list[i].discounts*10;
						if(dis==10){
							dis="不打折";
						}else{
							dis+="折";
						}
						str+="<tr><td>"+list[i].message+"会员"+"</td><td>"+dis+"</td><td>"+list[i].quota+"</td><td><button class='layui-btn' type='button' data-toggle='modal' data-target='#myModal1'>修改优惠<input type='hidden' value='"+list[i].id+"'/></button></td></tr>"
					}
					$("#viptbody").html(str)
				}
			}) 
		}
	})
	
}
$('#myModal1').on('hidden.bs.modal', function (){
	$("#vipdiscounts").val("")
	$("#quota").val("")
})
 function tan(){
    	$("#webSocketModal").modal('show')
    }
</script>
<script type="text/javascript">

var websocket = null;
//浏览器是否支持
if ('WebSocket' in window) {
  // 上面我们给webSocket定位的路径
  websocket = new WebSocket('ws://192.168.3.103:8080/webSocket');
} else {
  alert('该浏览器不支持websocket!');
}
//建立连接
websocket.onopen = function (event) {
  console.log('建立连接');
				
}
//关闭连接
websocket.onclose = function (event) {
  console.log('连接关闭');
}
//消息来的时候的事件
websocket.onmessage = function (event) {
  // 这里event.data就是我们从后台推送过来的消息
  console.log('收到消息:' + event.data);
  $('#message_content').append(event.data+'\n');
  // 在这里我们可以在页面中放置一个音乐，例如“您有新的订单了！”这样的提示音
  	document.getElementById("myAudio").play();
}

//发生错误时
websocket.onerror = function () {
  alert('websocket通信发生错误！');
}
//窗口关闭时，Websocket关闭
window.onbeforeunload = function () {
  websocket.close();
}

</script>
<audio src="../video/dingdong.mp3"  id="myAudio" ></audio>
</body>
</html>